/*
 * @文件描述:
 * @版本:
 * @作者:周晨阳
 * @Date:2021-11-20 13:39:59
 */
#include "Task.h"
#if BOARD_INUSE == BOARD_STM32
#include <rtthread.h>
#include "system.h"
#include "Sensor.h"

static struct rt_thread sensorThread_ptr;
static rt_uint8_t sensorThread_stack[400];
/**
 * @brief 传感器数据更新线程
 * 
 */
void updateSensorValue(void *p)
{
    while (1)
    {
        printf("A1 = %f ;\r\n", getAngle(ANGLE_1, PRESENT_ANGLE));
        printf("A2 = %f ;\r\n", getAngle(ANGLE_2, PRESENT_ANGLE));
        printf("A3 = %f ;\r\n", getAngle(ANGLE_3, PRESENT_ANGLE));
        printf("A4 = %f ;\r\n", getAngle(ANGLE_4, PRESENT_ANGLE));
        printf("A5 = %f ;\r\n", getAngle(ANGLE_5, PRESENT_ANGLE));
        printf("A6 = %f ;\r\n", getAngle(ANGLE_6, PRESENT_ANGLE));
        printf("A7 = %f ;\r\n", getAngle(HAND, PRESENT_ANGLE));
        rt_thread_mdelay(20);
    }
}
/**
 * @brief : 线程初始化
 */
void threadInit()
{
    rt_err_t result;
    rt_thread_t settingPtr;
    int i = 0;

    result = rt_thread_init(
        &sensorThread_ptr, "sensorThread", updateSensorValue, RT_NULL,
        &sensorThread_stack[0], sizeof(sensorThread_stack), 0, 500);

    if (result == RT_EOK)
    {
        printf("sensorThread started\n");
    }
    else
    {
        printf("ERROR:sensorThread not started\n");
    }
}
/**
 * @brief 执行任务
 * 
 */
void execute(void)
{
    threadInit();
    //rt_thread_startup(&sensorThread_ptr);
}

#endif
